'use strict';

//  standard definition for a stock
module.exports = app => {
  const {
    INTEGER,
    STRING,
    TEXT,
    DATE,
  } = app.Sequelize;

  const Stock = app.model.define('stock', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    name: {
      type: STRING,
      validate: {
        min: 2,
        max: 50,
      },
    },
    code: {
      type: STRING,
      validate: {
        min: 6,
        max: 10,
      },
    },
    summary: {        //  Short desc
      type: STRING,
      validate: {
        min: 2,
        max: 255,
      },
    },
    // content: {
    //   type: TEXT,
    // },
    // readSize: {
    //   type: INTEGER,
    //   defaultValue: 0,
    // },
    // commentSize: {
    //   type: INTEGER,
    //   defaultValue: 0,
    // },
    // tags: {
    //   type: STRING(100),
    // },
    // created_at: DATE,
    // updated_at: DATE,

  });

  // Stock.associate = function() {
  //   //app.model.Blog.belongsTo(app.model.User);
  //   //app.model.Stock.belongsTo(app.model.Catalog);
  //   // app.model.Blog.hasMany(app.model.Comment, {
  //   //   as: 'comment',
  //   // });
  // };
  return Stock;
};
